package sort;

import sort.cmp.*;
import tools.Integers;

import java.util.Arrays;

/**
 * @Author: LDeng
 * @Date: 2021-03-23 9:13
 */
public class Main {

    public static void main(String[] args) {
        Integer[] array = Integers.random(50000, 1, 50000);
       // Integer[] array = {7,3,5,8,6,7,4,5};
        testSorts(array,
//                new BubbleSort1(),
//                new BubbleSort2(),
//                new BubbleSort3(),
//                new HeapSort(),
//                new SelectionSort(),
//                new InsertionSort1(),
//                new InsertionSort2(),
//                new InsertionSort3(),
//                new MergeSort(),//可变参数
//                new QuickSort<>(),
//                new CountingSort(),
                    new RedixSort());

//        Integer[] array={2,4,8,8,8,12,14};
//        Asserts.test(BinarySearch.search(array,5)==2);
//        Asserts.test(BinarySearch.search(array,1)==0);
//        Asserts.test(BinarySearch.search(array,15)==7);
//        Asserts.test(BinarySearch.search(array,8)==5);

    }

    static void testSorts(Integer[] array, Sort... sorts) {

        for (Sort sort : sorts) {
            Integer[] newArray=Integers.copy(array);
            sort.sort(newArray);
            boolean ascOrder = Integers.isAscOrder(newArray);
            System.out.println(ascOrder);
            Integers.println(newArray);
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }

}
